<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('费率代号信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>费率代号：</label>
                                <input type="text" name="arMark"/>
                            </li>
                            <li>
                                <label>费率名称：</label>
                                <input type="text" name="arName"/>
                            </li>
                            <li>
                                <label>类型：</label>
                                <select name="arType" th:with="type=${@dict.getType('rate_type')}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add(370)" shiro:hasPermission="rateInfo:rateInfo:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="rateRule()" shiro:hasPermission="rateInfo:rateInfo:edit">
                    <i class="fa fa-edit"></i> 费率规则
                </a>
                <a class="btn btn-success" onclick="rateInfoDetail()" shiro:hasPermission="rateInfo:rateInfo:ruleTitle">
                    <i class="fa fa-edit"></i> 费率规则说明
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('rateInfo:rateInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('rateInfo:rateInfo:remove')}]];
        var rateType = [[${@dict.getType('rate_type')}]];
        var rateStatus = [[${@dict.getType('rate_status')}]];
        var prefix = ctx + "rateInfo/rateInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                clickToSelect: true,
                modalName: "费率代号信息",
                columns: [{
                    radio: true
                },
                {
                    field: 'arMark',
                    title: '费率代号'
                },
                {
                    field: 'arName',
                    title: '费率名称'
                },
                {
                    field: 'arContent',
                    title: '内容'
                },
                {
                    field: 'arType',
                    title: '类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(rateType, value);
                    }
                },
                {
                    field: 'arStatus',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(rateStatus, value);
                    }
                },
                {
                    field: 'addTime',
                    title: '添加时间'
                },
                {
                    field: 'addMan',
                    title: '添加人'
                }]
            };
            $.table.init(options);
        });

        function rateRule(){
            var rows = $.table.selectColumns("arMark");
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $.modal.open("配置费率规则", prefix+"/edit/"+rows,800,500);
        }

        function rateInfoDetail() {
            //如果是移动端，就使用自适应大小弹窗
            var url = prefix + '/ruleTitle/' ;
            var btn = ['关闭'];
            var options = {
                title: '费率规则说明',
                url: url,
                btn: btn,
                yes:function(index){
                    layer.close(index);
                }
            };
            $.modal.openOptions(options);
        }
    </script>
</body>
</html>